home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
8bit
/
cislib_b
/
timers.act
< prev
next >
Wrap
Text File
|
1995-04-22
|
3KB
|
122 lines
;************************************
;* *
;*(C)Copyright 1986 by Paul B. Loux *
;* *
;* These routines are in the public *
;* domain, and are not to be sold *
;* for a profit. They may be freely *
;* distributed, provided that this *
;* header remains in place. Use and *
;* enjoy! PBL, CIS 72337,2073. *
;* *
;************************************
;
; FILE: TIMERS.ACT
;
; This file contains a MODULE which
; provides the declarations needed
; to access the Atari OS timers. It
; includes the real-time clock (or
; "jiffy counter") starting at $12,
; plus the counters and interrupt
; vectors for countdown timers 2-5.
; In addition, a short demo program
; is provided to demonstrate how to
; install a timer-driven interrupt,
; and "multi-task" on your Atari.
;
; System timer 1 vectors are not in
; here, as they are used by the OS,
; to time I/O and other things. It
; can be used in certain cases, but
; I try to get along without it.
;
;************************************
;
; SIO system timer variables
;
MODULE
;
BYTE RTCLOK1=$12, ; Real time clock
RTCLOK2=$13,
RTCLOK3=$14
CARD CDTMV2=$21A ; SIO timer 2
CARD CDTMV3=$21C ; SIO timer 3
CARD CDTMV4=$21E ; SIO timer 4
CARD CDTMV5=$220 ; SIO timer 5
CARD CDTMA2=$228 ; timer 2 vector
BYTE CDTMF3=$22A ; timer 3 flag
BYTE CDTMF4=$22C ; timer 4 flag
BYTE CDTMF5=$22E ; timer 5 flag
;
;************************************
MODULE
CARD ctr,ctr2,limit
PROC SETCLOCK() ; zero real-
RTCLOK1=0 ; time clock
RTCLOK2=0
RTCLOK3=0
RETURN
PROC READCLOCK() ; show elapsed-
; time in jiffies
BYTE rt1,rt2,rt3
rt1=RTCLOK1
rt2=RTCLOK2
rt3=RTCLOK3
POSITION(10,20)
PRINTB(rt1) PRINT(" ")
PRINTB(rt2) PRINT(" ")
PRINTB(rt3) PRINT(" ")
RETURN
PROC INTRPT() ; timer IRQ routine
CDTMV2=limit ; reset timer
ctr==+1 ; # times here
RETURN
PROC TEST()
BYTE CH=764 ; keystroke pending
CARD save
ctr=0 ctr2=0
limit=60 ; 60 jiffy wait
save=CDTMA2 ; save old vector
SETCLOCK() ; zero clock
CDTMA2=INTRPT ; point vector
CDTMV2=limit ; start countdown
DO
ctr2==+1
POSITION(10,10)
PRINTC(ctr) ; # of timer IRQ's
POSITION(10,15)
PRINTC(ctr2) ; # of times here
READCLOCK() ; elapsed time
UNTIL CH#255 ; press any
OD ; key to stop
limit=0
CDTMA2=save ; restore vector
CH=255 ; clear keystroke
RETURN